package com.wn.controller;

import com.wn.bean.Result;
import com.wn.bean.ResultCode;
import io.swagger.v3.oas.models.security.SecurityScheme;

import static com.wn.bean.ResultEnumCode.SUCCESS;

public class BaseController {

    public Result success() {
        return new Result(ResultCode.SUCCESS, "操作成功");
    }

    public Result successEnum() {
        return new Result(SUCCESS.getCode(), "操作成功");
    }

    public Result error() {
        return new Result(ResultCode.ERROR, "操作失败");
    }

    public Result toResult(Integer row) {
        return row > 0 ? success() : error();
    }

    public Result toResult(Boolean flag) {
        return flag? success() : error();
    }

    public Result toDataResult(Object data) {
        return new Result(ResultCode.SUCCESS,"查询数据成功",data);
    }



}
